<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head th:replace="/user/common/CSSandJS1 :: head('登  录')"></head>

<body>
<h1 th:text="${msg}">213</h1>

<!--wrapper start-->
<div class="wrapper">
<!--  <h1 th:text="${msg}">Testssssssssssssss</h1>-->
  <!--== Start Preloader Content ==-->
  <div class="preloader-wrap">

    <div class="preloader">
      <span class="dot"></span>
      <div class="dots">
        <span></span>
        <span></span>
        <span></span>
      </div>
    </div>
  </div>
  <!--== End Preloader Content ==-->

  <!--== Start Header Wrapper ==-->
  <div  th:replace="/user/common/header2 :: header(${cartList}, ${totalMoney})"></div>
  <!--== End Header Wrapper ==-->
  
  <main class="main-content">
    <!--== Start Page Header Area Wrapper ==-->
    <div class="page-header-area">
      <div class="container">
        <div class="row">
          <div class="col-12 text-center">
            <div class="page-header-content">
              <nav class="breadcrumb-area">
                <ul class="breadcrumb">
                  <li><a href="index.html">Home</a></li>
                  <li class="breadcrumb-sep">/</li>
                  <li>Account</li>
                </ul>
              </nav>
              <h4 class="title">Account</h4>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--== End Page Header Area Wrapper ==-->

    <!--== Start Account Area Wrapper ==-->
    <section class="account-area">
      <div class="container">
        <div class="row">
          <div class="col-lg-6 col-md-8 m-auto">
            <div class="account-form-wrap">
              <!--== Start Login Form ==-->
              <div class="login-form">
                <div class="content">
                  <h4 class="title">Login</h4>
                  <p>Please login using account detail bellow.</p>
                  <!--/*@thymesVar id="msg" type=""*/-->
<!--                  <p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>-->
                  <p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>
                </div>
                <form th:action="@{/main/user/login}">
                  <div class="row">
                    <div class="col-12">
                      <div class="form-group">
                        <input th:id="username" class="form-control" type="text" placeholder="Usernaem" name="username">
                      </div>
                    </div>
                    <div class="col-12">
                      <div class="form-group">
                        <input th:id="password" class="form-control" type="password" placeholder="Password" name="password">
                      </div>
                    </div>
                    <div class="col-12">
                      <div class="login-form-group">
                        <button th:id="login" class="btn-sign" th:type="button">Sign In</button>
                        <a class="btn-pass-forgot" href="#/">Forgot your password?</a>
                      </div>
                    </div>
                    <div class="col-12">
                      <div class="account-optional-group">
                        <a class="btn-create" th:href="@{/user/register}">Create account?</a>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
              <!--== End Login Form ==-->
            </div>
          </div>
        </div>
      </div>
    </section>
    <!--== End Account Area Wrapper ==-->
  </main>

  <!--== Start Footer Area Wrapper ==-->
  <div  th:replace="/user/common/footer"></div>
  <!--== End Footer Area Wrapper ==-->

  <!--== Scroll Top Button ==-->
  <div id="scroll-to-top" class="scroll-to-top"><span class="fa fa-angle-double-up"></span></div>

  <!--== Start Quick View Menu ==-->
  <div th:replace="/user/common/aside"></div>
  <!--== End Side Menu ==-->
</div>

<!--=======================Javascript============================-->
<div th:replace="/user/common/CSSandJS1 :: js"></div>
<script>

  $("#login").click(function () {
    let name = $("#username").val();
    let pwd = $("#password").val();

      $.ajax({
          url: "/user/loginjudge",
          type: "get",
          data: {"name": name, "pwd": pwd},
          success: function (res){
            if(res === "ok"){
              layer.msg('登录成功。');
              console.log('res===='+res);
              location.href="/user/index";
            }else{
              layer.msg('用户名或密码有误请重新输入！');
            }
          }
        });
      });
</script>
</body>

</html>